package win.bojack.redis_learning;

import java.util.Random;

public class VerifyCode {
    public static void main(String[] args) {
        for (int i = 0;i<100;i++) {
            System.out.println(genCode(4));
        }
    }



    static String genCode(int length) {
        if (length < 4 || length > 10) {
            throw new RuntimeException(String.format("验证码长度%s太短或太长", (length)));
        }
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i =0;i<length;i++) {
            sb.append(random.nextInt(9));
        }

        return sb.toString();
    }
}
